import { PORT1 } from '@/api/config/servicePort'
import http from '@/api'

/**
 * @name 角色管理模块
 */
// 获取角色列表
export const getRolePageListApi = (params) => {
  return http.get(PORT1 + `/SysRole/PageList`, params)
}
//添加与修改已有角色接口方法
export const reqAddOrUpdateRoleApi = (data) => {
  //修改已有角色的数据
  if (data.id) {
    return http.put(PORT1 + `/SysRole/Update`, data)
  } else {
    //新增角色
    return http.post(PORT1 + `/SysRole/Add`, data)
  }
}

//删除某一个已有角色的数据
export const reqDeleteRoleApi = (id) =>
  http.delete(PORT1 + `/SysRole/Delete/` + id)

export const reqGetRoleMenuApi = (roleid) =>
  http.get(PORT1 + `/SysRoleMenu/GetRoleMenu`, { roleid })

export const reqUpdateRoleMenuApi = (data) =>
  http.post(PORT1 + `/SysRoleMenu/Add`, data)

export const getRoleListApi = () => {
  return http.get(PORT1 + `/SysRole/List`)
}
